package link.anyauto.study;

import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ExpandableListView;

import link.anyauto.study.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        binding.setHandlers(new Handlers());
        ExpandableAdapter adapter = new ExpandableAdapter();
        adapter.data = new Data();
        for(int i=0; i<15; i++) {
            Functions functions = new Functions();
            functions.name = "Group " + (i + 1);
            adapter.data.functions.add(functions);
            for(int j=0; j<15; j++) {
                functions.funs.add("Function " + (i + 1) + ", " + (j + 1));
            }
        }
        binding.list.setAdapter(adapter);
        binding.setData(adapter.data);
//        binding.list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
//            @Override
//            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
//                Log.e("clicked", "child -> " + groupPosition + ", " + childPosition);
//                return false;
//            }
//        });
    }
}
